/*
struct ListNode {
	int val;
	struct ListNode *next;
	ListNode(int x) :
			val(x), next(NULL) {
	}
};*/
class Solution {
public:
	ListNode* FindFirstCommonNode(ListNode* pHead1, ListNode* pHead2) {
		std::unordered_map<ListNode*, int> _map;
		while (pHead1)
		{
			_map[pHead1]++;
			pHead1 = pHead1->next;
		}
		while (pHead2)
		{
			_map[pHead2]++;
			if (_map[pHead2] == 2)
			{
				return pHead2;
			}
			pHead2 = pHead2->next;
		}
		return nullptr;
	}
};
